home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / findarg.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  106 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: findarg.c,v 1.3 1996/08/13 13:52:46 digulla Exp $
  4.     $Log: findarg.c,v $
  5.     Revision 1.3  1996/08/13 13:52:46  digulla
  6.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  7.     Replaced __AROS_LA by __AROS_LHA
  8.  
  9.     Revision 1.2  1996/08/01 17:40:50  digulla
  10.     Added standard header for all files
  11.  
  12.     Desc:
  13.     Lang: english
  14. */
  15. #include <clib/utility_protos.h>
  16. #include "dos_intern.h"
  17.  
  18. /*****************************************************************************
  19.  
  20.     NAME */
  21.     #include <clib/dos_protos.h>
  22.  
  23.     __AROS_LH2(LONG, FindArg,
  24.  
  25. /*  SYNOPSIS */
  26.     __AROS_LHA(STRPTR, template, D1),
  27.     __AROS_LHA(STRPTR, keyword,  D2),
  28.  
  29. /*  LOCATION */
  30.     struct DosLibrary *, DOSBase, 134, Dos)
  31.  
  32. /*  FUNCTION
  33.  
  34.     INPUTS
  35.  
  36.     RESULT
  37.  
  38.     NOTES
  39.  
  40.     EXAMPLE
  41.  
  42.     BUGS
  43.  
  44.     SEE ALSO
  45.  
  46.     INTERNALS
  47.  
  48.     HISTORY
  49.     29-10-95    digulla automatically created from
  50.                 dos_lib.fd and clib/dos_protos.h
  51.  
  52. *****************************************************************************/
  53. {
  54.     __AROS_FUNC_INIT
  55.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  56.  
  57.     LONG count=0;
  58.     STRPTR key;
  59.  
  60.     /* Loop over template */
  61.     for(;;)
  62.     {
  63.     /* Compare key to template */
  64.     key=keyword;
  65.     for(;;)
  66.     {
  67.         /* If the keyword has ended check the template */
  68.         if(!*key)
  69.         {
  70.         if(!*template||*template=='='||*template=='/'||*template==',')
  71.             /* The template has ended, too. Return count. */
  72.             return count;
  73.         /* The template isn't finished. Stop comparison. */
  74.         break;
  75.         }
  76.         /* If the two differ stop comparison. */
  77.         if(ToLower(*key)!=ToLower(*template))
  78.         break;
  79.         /* Go to next character */
  80.         key++;
  81.         template++;
  82.     }
  83.     /* Find next keyword in template */
  84.     for(;;)
  85.     {
  86.         if(!*template)
  87.         return -1;
  88.         if(*template=='=')
  89.         {
  90.         /* Alias found */
  91.         template++;
  92.         break;
  93.         }
  94.         if(*template==',')
  95.         {
  96.         /* Next item found */
  97.         template++;
  98.         count++;
  99.         break;
  100.         }
  101.         template++;
  102.     }
  103.     }
  104.     __AROS_FUNC_EXIT
  105. } /* FindArg */
  106.